package wh;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class PacketStreamWriter
{
  private byte[] m_byteBuffer;
  public DataOutputStream m_oStream = new DataOutputStream(this.m_bOStream);
  private ByteArrayOutputStream m_bOStream = new ByteArrayOutputStream();
  private DataOutputStream m_dOutputStream;
  int m_lastSize;

  public void reset()
  {
    this.m_bOStream.reset();
    this.m_lastSize = this.m_oStream.size();
  }

  public void sendPacket()
    throws IOException
  {
    int i = this.m_oStream.size() - this.m_lastSize;
    this.m_dOutputStream.writeShort(i);
    this.m_byteBuffer = this.m_bOStream.toByteArray();
    this.m_dOutputStream.write(this.m_byteBuffer, 0, i);
    this.m_dOutputStream.flush();
    this.m_lastSize = this.m_oStream.size();
    this.m_bOStream.reset();
  }

  public PacketStreamWriter(OutputStream paramOutputStream)
  {
    this.m_dOutputStream = new DataOutputStream(paramOutputStream);
  }

  public DataOutputStream getStream()
  {
    return this.m_oStream;
  }
}

/* Location:           /Users/MacOSX/Wormhole/
 * Qualified Name:     PacketStreamWriter
 * JD-Core Version:    0.5.4
 */